package com.autumn.sms.service.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.autumn.application.dto.PageQueryResult;
import com.autumn.application.dto.input.DefaultPrimaryKeyInput;
import com.autumn.application.dto.input.PageQueryInput;
import com.autumn.sms.service.consts.UrlConsts;
import com.autumn.sms.service.services.IPlatformInfoService;
import com.autumn.sms.service.services.dto.input.PlatformInfoInput;
import com.autumn.sms.service.services.dto.input.PlatformInfoUpdateInput;
import com.autumn.sms.service.services.dto.output.PlatformInfoOutput;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 平台信息控制器
 * 
 * @author JuWa ▪ Zhang
 * @date 2018年1月17日
 * @since jdk 1.8
 */
@Api(tags = "短信后台-平台")
@RestController
@RequestMapping(UrlConsts.PLATFORM)
public class PlatformInfoController {
	@Autowired
	private IPlatformInfoService service;

	@GetMapping("/get")
	@ApiOperation("获取平台信息")
	public PlatformInfoOutput get(@Valid DefaultPrimaryKeyInput input) {
		return service.get(input);
	}

	@PostMapping("/add")
	@ApiOperation("新增平台信息")
	public PlatformInfoOutput add(@Valid @RequestBody PlatformInfoInput input) {
		return service.add(input);
	}

	@PostMapping("/modify")
	@ApiOperation("更新平台信息")
	public PlatformInfoOutput modify(@Valid @RequestBody PlatformInfoUpdateInput input) {
		return service.modify(input);
	}

	@PostMapping("/delete")
	@ApiOperation("/删除平台信息")
	public void delete(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.delete(input);
	}

	@PostMapping("/release")
	@ApiOperation("发布平台信息")
	public void release(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.release(input);
	}

	@PostMapping("/disable")
	@ApiOperation("停用平台")
	public void disable(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.disable(input);
	}

	@GetMapping("/list")
	@ApiOperation("获取平台信息列表")
	public List<PlatformInfoOutput> list() {
		return service.list();
	}
	
	@PostMapping("/pagequery")
	@ApiOperation("分页获取平台信息")
	public PageQueryResult<PlatformInfoOutput> pageQuery(@Valid @RequestBody PageQueryInput input) {
		return service.pageQuery(input);
	}
}
